﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace StuDormManage
{
    public partial class frmRegit : Form
    {
        StuDormManage.sqlConnect con = new StuDormManage.sqlConnect();
        public DataSet ds = new DataSet();
        private string sql;
        public frmRegit()
        {
            InitializeComponent();
            SetBind();
        }

        protected void SetBind()
        {
            try
            {
                sql = "select Acount as 用户名,Password as 密码 from Login";
                ds = con.BindDataGridView(dataGView, sql);
                dataGView.Columns[0].ReadOnly = true;
                dataGView.AllowUserToAddRows = false;
            }
            catch
            {
                //MessageBox.Show("不能做该操作！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }


        private void frmRegit_Load(object sender, EventArgs e)
        {

        }

        private void btnRegit_Click(object sender, EventArgs e)
        {
            try
            {
                sql = "insert into Login values( '" + txtAcount.Text + "','" + txtPwd.Text + "')";
                con.OperateData(sql);
                SetBind();
                MessageBox.Show("注册成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                StuDormManage.frmLogin fLogin = new StuDormManage.frmLogin();
                fLogin.Show();
                this.Hide();
            }
            catch
            {
                MessageBox.Show("不能做该操作！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            StuDormManage.frmLogin fLogin = new StuDormManage.frmLogin();
            fLogin.Show();
            this.Dispose();
        }
    }
}
